/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package com.smg.community.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.smg.community.model.*;
import com.smg.community.dao.*;
import com.smg.community.service.*;
import com.smg.community.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


import org.springframework.stereotype.Repository;


@Repository
public class SmgMemberBehaviorDao extends BaseIbatis3Dao<SmgMemberBehavior,java.lang.Integer>{
	
	@Override
	public String getIbatisMapperNamesapce() {
		return "SmgMemberBehavior";
	}
	
	public void saveOrUpdate(SmgMemberBehavior entity) {
		if(entity.getBehaviorId() == null) 
			save(entity);
		else 
			update(entity);
	}
	
	public Page findPage(SmgMemberBehaviorQuery query) {
		return pageQuery("SmgMemberBehavior.findPage",query);
	}

	public SmgMemberBehavior getLastestByMemberId(String memberId) {
		return (SmgMemberBehavior)this.getSqlSessionTemplate().selectOne("SmgMemberBehavior.getLastestByMemberId", memberId);
	}

	public List getFourBehavior() {
		return  (List)this.getSqlSessionTemplate().selectOne("SmgMemberBehavior.getFourBehavior", null);
	}

	public List<SmgMemberBehavior> getJoinActivityBehavior() {
		return (List)this.getSqlSessionTemplate().selectList("SmgMemberBehavior.getJoinActivityBehavior", null);
	}

	public SmgMemberBehavior getMemberBehaviorByType(Integer memberId, int type) {
		Map map = new HashMap();
		map.put("memberId",memberId);
		map.put("type",type);
		return (SmgMemberBehavior)this.getSqlSessionTemplate().selectOne("SmgMemberBehavior.getMemberBehaviorByType", map);
	}
	

}
